// pages/report/reportTypeList/reportTypeList.js
const app=getApp()
import {
    getRequestUrlHeader
} from '../../../utils/util';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    navbarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '评测报告', //导航栏 中间的标题
    },
    navHeight: app.globalData.statusBarHeight * 2 + 86,
    deptId: app.globalData.deptId,
    userId:''
  },
  onShow() {
     
    this.setData({
      deptId: app.globalData.deptId
    })
    // this.getPatientId()
  },
  // 获取用户id
  async getPatientId(){
    let { userId, account, currentPatient, deptId } = app.globalData;
    let { userName, birthday, tenantId, phoneNo, gender, pregnancyDay } = currentPatient;
    let baseApi = await getRequestUrlHeader(tenantId)
    wx.request({
        url: app.getWebUrl(baseApi+'/nirn/platform/scale/patient'),
        method: 'POST',
        data: {
            accountId:account,
            birthday:birthday,
            gender:gender=='N'?1:0,
            patientId:userId,
            patientName:userName,
            phoneNum:phoneNo,
            tenantId:tenantId
        },
        success(res) {
            console.log('res',res)
            this.setData({
                userId:res.data.id
            })
        }
    })
    console.log('userId',userId)
  },
  // 获取报告列表
  getScaleList(){
    wx.request({
        url: app.getWebUrl(baseApi+'/nirn/platform/scale/patient'),
        method: 'POST',
        data: {
            patientId: this.data.userId
        },
        success(res) {
            console.log('res',res)
            this.setData({
                userId:res.data.id
            })
        }
    })
  },
  handleToNBNA: function () {
   let url = encodeURIComponent(app.globalData.config.webServer + '/H5/view-html/scale/html/complex/nbna.html');
  //  let url = encodeURIComponent(app.globalData.config.webServer +'/views/ccquestionnaire/quest');
    wx.navigateTo({
      url: '../webview/webview?url=' + url+ '&proxy=true'
    })
  },
  handleToEX2: function () {
    let url = encodeURIComponent(app.globalData.config.webServer + '/H5/view-html/scale/html/complex/ex2.html');
    wx.navigateTo({
      url: '../webview/webview?url=' + url + '&proxy=true',
    })
  },
  handleToBISQ: function () {
    let url = encodeURIComponent(app.globalData.config.webServer + '/H5/view-html/scale/html/complex/BISQ.html');
    wx.navigateTo({
      url: '../webview/webview?url=' + url + '&proxy=true',
    })
  },
  handleToCSHQ: function () {
    let url = encodeURIComponent(app.globalData.config.webServer + '/H5/view-html/scale/html/complex/CSHQ.html');
    wx.navigateTo({
      url: '../webview/webview?url=' + url + '&proxy=true',
    })
  },
  handleToPEBS: function (e) {
    console.log('eeee',app.globalData.config)
    // let url = encodeURIComponent(app.globalData.config.webServer + '/H5/view-html/scale/html/complex/PEBS.html');
    // let url = encodeURIComponent(app.globalData.config.webServer + '/H5/view-html/scale/html/index.html');
    let url = encodeURIComponent(app.globalData.config.webServer + '/index.html');
    wx.navigateTo({
      url: `../webview/webview?url=${url}&proxy=true&scaleUuid=${e.currentTarget.dataset.scaleuuid}`,
    })
  },
  toGrowthRecord:function(){
    wx.navigateTo({
      url: '../growthRecord/growthRecord',
    })
  }
})